﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace cryptography
{
    /* Version 0.8
     * New Feautures:
     * - Change size of cipher
     * Version 0.7
     * Features:
     * + Save Cipher Text
     *      - Double Click in Cipher field
     * + Generator PlainText from character set
     *      - OK
     */
    public partial class SubstituionCipher : Form
    {
        public SubstituionCipher()
        {
            // set list of ciphers
            lstCiphers = new List<string>(new String[] { "Pigpen Cipher", "Bionicle Cipher" });
            // set list of character set
            lstCharactersets = new List<string>(new String[] { "abcdefghijklmnopqrstuvwxyz ", "abcdefghijklmnopqrstuvwxyz0123456789 "});
            
            // init for drawing
            num_chars_per_line = 20;
            offset_x = 5;
            offset_y = 5;

            character_set = "abcdefghijklmnopqrstuvwxyz ";

            InitializeComponent();

            // create bitmap cipher
            myBitmap = new Bitmap(500, 300);
            graphicsObj = Graphics.FromImage(myBitmap);

            // create bitmap character set
            bitmapCharacterSet = new Bitmap(500, 300);
            graphicsCharacterSet = Graphics.FromImage(bitmapCharacterSet);
            picCharacterSet.Image = bitmapCharacterSet;
            // create pen and brush
            myPen = new Pen(System.Drawing.Color.Red, 1);
            myBrush = new SolidBrush(Color.Red);    

            // select combo box
            currentCipherType = 0;
            comboBox1.SelectedIndex = currentCipherType;
        }
        
        private void Draw_Cipher(Graphics g, String plain)
        {
            int i = 0;
            int j = 0;
            foreach(Char p in plain){
                switch(currentCipherType){
                    case 0:
                        DrawCipherCharacter0(g, p, i, j);
                        break;
                    case 1:
                        DrawCipherCharacter1(g, p, i, j, Color.Black);
                        break;
                    default:
                        break;
                }
                
                i += 1;
                if (i > num_chars_per_line){
                    j += 1;
                    i = 0;
                }
            }
        }


        // draw pigpen cipher
        private void DrawCipherCharacter0(Graphics g, Char p, int i, int j){
            int x = 20 * i + offset_x;
            int y = 20 * j + offset_y;
            switch (p)
            {
                case 'a':
                    g.DrawLine(myPen, x + 10, y, x + 10, y + 10);
                    g.DrawLine(myPen, x + 10, y + 10, x, y + 10);
                    break;
                case 'b':
                    g.DrawLine(myPen, x, y, x, y + 10);
                    g.DrawLine(myPen, x, y + 10, x + 10, y + 10);
                    g.DrawLine(myPen, x + 10, y + 10, x + 10, y);
                    break;
                case 'c':
                    g.DrawLine(myPen, x, y, x, y + 10);
                    g.DrawLine(myPen, x, y + 10, x + 10, y + 10);
                    break;
                case 'd':
                    g.DrawLine(myPen, x, y, x + 10, y);
                    g.DrawLine(myPen, x + 10, y, x + 10, y + 10);
                    g.DrawLine(myPen, x, y + 10, x + 10, y + 10);
                    break;
                case 'e':
                    g.DrawLine(myPen, x, y, x + 10, y);
                    g.DrawLine(myPen, x + 10, y, x + 10, y + 10);
                    g.DrawLine(myPen, x + 10, y + 10, x, y + 10);
                    g.DrawLine(myPen, x, y, x, y + 10);
                    break;
                case 'f':
                    g.DrawLine(myPen, x, y, x + 10, y);
                    g.DrawLine(myPen, x + 10, y + 10, x, y + 10);
                    g.DrawLine(myPen, x, y, x, y + 10);
                    break;
                case 'g':
                    g.DrawLine(myPen, x, y, x + 10, y);
                    g.DrawLine(myPen, x + 10, y, x + 10, y + 10);
                    break;
                case 'h':
                    g.DrawLine(myPen, x, y, x + 10, y);
                    g.DrawLine(myPen, x + 10, y, x + 10, y + 10);
                    g.DrawLine(myPen, x, y, x, y + 10);
                    break;
                case 'i':
                    g.DrawLine(myPen, x, y, x + 10, y);
                    g.DrawLine(myPen, x, y, x, y + 10);
                    break;
                case 'j':
                    DrawCipherCharacter0(g,'a', i, j);
                    DrawCipherCharacter0(g,'.', i, j);
                    break;
                case 'k':
                    DrawCipherCharacter0(g,'b', i, j);
                    DrawCipherCharacter0(g,'.', i, j);
                    break;
                case 'l':
                    DrawCipherCharacter0(g,'c', i, j);
                    DrawCipherCharacter0(g,'.', i, j);
                    break;
                case 'm':
                    DrawCipherCharacter0(g,'d', i, j);
                    DrawCipherCharacter0(g,'.', i, j);
                    break;
                case 'n':
                    DrawCipherCharacter0(g,'e', i, j);
                    DrawCipherCharacter0(g,'.', i, j);
                    break;
                case 'o':
                    DrawCipherCharacter0(g,'f', i, j);
                    DrawCipherCharacter0(g,'.', i, j);
                    break;
                case 'p':
                    DrawCipherCharacter0(g,'g', i, j);
                    DrawCipherCharacter0(g,'.', i, j);
                    break;
                case 'q':
                    DrawCipherCharacter0(g,'h', i, j);
                    DrawCipherCharacter0(g,'.', i, j);
                    break;
                case 'r':
                    DrawCipherCharacter0(g,'i', i, j);
                    DrawCipherCharacter0(g,'.', i, j);
                    break;
                case 's':
                    g.DrawLine(myPen, x, y, x + 5, y + 10);
                    g.DrawLine(myPen, x + 5, y + 10, x + 10, y);
                    break;
                case 't':
                    g.DrawLine(myPen, x, y, x + 10, y + 5);
                    g.DrawLine(myPen, x + 10, y + 5, x, y + 10);
                    break;
                case 'u':
                    g.DrawLine(myPen, x + 10, y, x, y + 5);
                    g.DrawLine(myPen, x, y + 5, x + 10, y + 10);
                    break;
                case 'v':
                    g.DrawLine(myPen, x, y + 10, x + 5, y);
                    g.DrawLine(myPen, x + 5, y, x + 10, y + 10);
                    break;
                case 'w':
                    DrawCipherCharacter0(g,'s', i, j);
                    DrawCipherCharacter0(g,'.', i, j);
                    break;
                case 'x':
                    DrawCipherCharacter0(g,'t', i, j);
                    DrawCipherCharacter0(g,'.', i, j);
                    break;
                case 'y':
                    DrawCipherCharacter0(g,'u', i, j);
                    DrawCipherCharacter0(g,'.', i, j);
                    break;
                case 'z':
                    DrawCipherCharacter0(g,'v', i, j);
                    DrawCipherCharacter0(g,'.', i, j);
                    break;
                case '.':
                    g.FillEllipse(myBrush, x + 4, y + 4, 3, 3);
                    break;
                default:
                    break;
            }
        }
        // draw bionicle cipher
        private void DrawCipherCharacter1(Graphics g, Char p, int i, int j, Color backcolor){
            int maxSize = 10;
            int halfSize = maxSize / 2;
            int quarterSize = maxSize / 4;
            Brush myBrush = new SolidBrush(backcolor);
            // offset for draw circle
            int offsetSize = maxSize / 15;
            // for drawing circle in diogonal
            int paddingSize = (int) ((float) maxSize / 6.85);
            int smallCircleSize = maxSize / 5;
            int halfSmallCircleSize = smallCircleSize/2;
            int offsetCircleSize = smallCircleSize / 4;
            int x = maxSize * i * 2 + offset_x;
            int y = maxSize * j * 2 + offset_y;
            switch(p){
                case 'a':
                    g.DrawEllipse(myPen, x, y, maxSize, maxSize);
                    g.DrawEllipse(myPen, x + halfSize - halfSmallCircleSize, y + maxSize - smallCircleSize - offsetCircleSize, smallCircleSize, smallCircleSize);
                    break;
                case 'b':
                    g.DrawEllipse(myPen, x, y, maxSize, maxSize);
                    g.DrawEllipse(myPen, x + halfSize - halfSmallCircleSize, y + maxSize - smallCircleSize - offsetCircleSize, smallCircleSize, smallCircleSize);
                    g.DrawEllipse(myPen, x + halfSize - halfSmallCircleSize, y + offsetCircleSize, smallCircleSize, smallCircleSize);
                    break;
                case 'c':
                    g.DrawEllipse(myPen, x, y, maxSize, maxSize);
                    g.DrawEllipse(myPen, x + maxSize - offsetCircleSize - smallCircleSize, y + halfSize - halfSmallCircleSize, smallCircleSize, smallCircleSize);
                    break;
                case 'd':
                    g.DrawEllipse(myPen, x, y, maxSize, maxSize);
                    g.DrawEllipse(myPen, x + maxSize - offsetCircleSize - smallCircleSize, y + halfSize - halfSmallCircleSize, smallCircleSize, smallCircleSize);
                    g.DrawLine(myPen, x + halfSize, y, x + halfSize, y + maxSize);
                    break;
                case 'e':
                    g.DrawEllipse(myPen, x, y, maxSize, maxSize);
                    g.DrawLine(myPen, x + paddingSize + offsetSize, y + paddingSize, x + maxSize - paddingSize - offsetSize, y + paddingSize);
                    g.DrawLine(myPen, x + paddingSize + offsetSize, y + maxSize - paddingSize, x + maxSize - paddingSize - offsetSize, y + maxSize - paddingSize);
                    break;
                case 'f':
                    g.DrawEllipse(myPen, x, y, maxSize, maxSize);
                    g.DrawLine(myPen, x + paddingSize + offsetSize, y + paddingSize, x + maxSize - paddingSize - offsetSize, y + paddingSize);
                    break;
                case 'g':
                    g.DrawEllipse(myPen, x, y, maxSize, maxSize);
                    g.DrawLine(myPen, x + halfSize, y, x + halfSize, y + maxSize);
                    g.DrawLine(myPen, x + halfSize, y + halfSize, x + maxSize, y + halfSize);
                    break;
                case 'h':
                    g.DrawEllipse(myPen, x, y, maxSize, maxSize);
                    g.DrawLine(myPen, x + quarterSize, y + offsetSize, x + quarterSize, y + maxSize - offsetSize);
                    g.DrawLine(myPen, x + halfSize + quarterSize, y + offsetSize, x + halfSize + quarterSize, y + maxSize - offsetSize);
                    g.DrawEllipse(myPen, x + halfSize - halfSmallCircleSize, y + maxSize - smallCircleSize - offsetCircleSize, smallCircleSize, smallCircleSize);
                    g.DrawEllipse(myPen, x + halfSize - halfSmallCircleSize, y + offsetCircleSize, smallCircleSize, smallCircleSize);
                    break;
                case 'i':
                    g.DrawEllipse(myPen, x, y, maxSize, maxSize);
                    g.DrawLine(myPen, x + halfSize, y, x + halfSize, y + maxSize);
                    break;
                case 'j':
                    g.DrawEllipse(myPen, x, y, maxSize, maxSize);
                    g.DrawLine(myPen, x + halfSize, y, x + halfSize, y + maxSize);
                    g.DrawEllipse(myPen, x + paddingSize, y + maxSize - paddingSize - smallCircleSize, smallCircleSize, smallCircleSize);
                    break;
                case 'k':
                    g.DrawEllipse(myPen, x, y, maxSize, maxSize);
                    g.DrawPie(myPen, x, y, maxSize, maxSize, -180, 135);
                    g.DrawPie(myPen, x, y, maxSize, maxSize, -45, 90);
                    break;
                case 'l':
                    g.DrawEllipse(myPen, x, y, maxSize, maxSize);
                    g.DrawLine(myPen, x + halfSize, y, x + halfSize, y + maxSize);
                    g.DrawEllipse(myPen, x + maxSize - paddingSize - smallCircleSize, y + maxSize - paddingSize - smallCircleSize, smallCircleSize, smallCircleSize);
                    break;
                case 'm':
                    g.DrawEllipse(myPen, x, y, maxSize, maxSize);
                    g.DrawLine(myPen, x + quarterSize, y + offsetSize, x + quarterSize, y + maxSize - offsetSize);
                    g.DrawLine(myPen, x + halfSize + quarterSize, y + offsetSize, x + halfSize + quarterSize, y + maxSize - offsetSize);
                    break;
                case 'n':
                    g.DrawEllipse(myPen, x, y, maxSize, maxSize);
                    g.DrawPie(myPen, x, y, maxSize, maxSize, -135, 180);
                    break;
                case 'o':
                    g.DrawEllipse(myPen, x, y, maxSize, maxSize);
                    break;
                case 'p':
                    g.DrawEllipse(myPen, x, y, maxSize, maxSize);
                    g.DrawLine(myPen, x + halfSize, y, x + halfSize, y + maxSize);
                    g.DrawEllipse(myPen, x + maxSize - paddingSize - smallCircleSize, y + paddingSize, smallCircleSize, smallCircleSize);
                    break;
                case 'q':
                    g.DrawEllipse(myPen, x, y, maxSize, maxSize);
                    g.DrawEllipse(myPen, x + maxSize - paddingSize - smallCircleSize, y + maxSize - paddingSize - smallCircleSize, smallCircleSize, smallCircleSize);
                    break;
                case 'r':
                    g.DrawEllipse(myPen, x, y, maxSize, maxSize);
                    g.DrawLine(myPen, x + halfSize, y, x + halfSize, y + maxSize);
                    g.DrawLine(myPen, x + halfSize, y + halfSize, x + maxSize, y + halfSize);
                    g.DrawEllipse(myPen, x + maxSize - paddingSize - smallCircleSize, y + paddingSize, smallCircleSize, smallCircleSize);
                    break;
                case 's':
                    g.DrawEllipse(myPen, x, y, maxSize, maxSize);
                    g.DrawEllipse(myPen, x + maxSize - paddingSize - smallCircleSize, y + paddingSize, smallCircleSize, smallCircleSize);
                    g.DrawEllipse(myPen, x + paddingSize, y + maxSize - paddingSize - smallCircleSize, smallCircleSize, smallCircleSize);
                    break;
                case 't':
                    g.DrawEllipse(myPen, x, y, maxSize, maxSize);
                    g.DrawLine(myPen, x, y + halfSize, x + maxSize, y + halfSize);
                    g.DrawLine(myPen, x + halfSize, y + halfSize, x + halfSize, y + maxSize);
                    break;
                case 'u':
                    g.DrawEllipse(myPen, x, y, maxSize, maxSize);
                    g.DrawEllipse(myPen, x + halfSize - halfSmallCircleSize, y + offsetCircleSize, smallCircleSize, smallCircleSize);
                    break;
                case 'v':
                    g.DrawEllipse(myPen, x, y, maxSize, maxSize);
                    g.DrawEllipse(myPen, x + halfSize - halfSmallCircleSize, y + offsetCircleSize, smallCircleSize, smallCircleSize);
                    g.DrawPie(myPen, x, y, maxSize, maxSize, -135, 90);
                    g.DrawPie(myPen, x, y, maxSize, maxSize, 45, 90);
                    break;
                case 'w':
                    g.DrawEllipse(myPen, x, y, maxSize, maxSize);
                    g.DrawPie(myPen, x, y, maxSize, maxSize, -135, 90);
                    g.DrawPie(myPen, x, y, maxSize, maxSize, 45, 90);
                    g.DrawEllipse(myPen, x + maxSize - offsetCircleSize - smallCircleSize, y + halfSize - halfSmallCircleSize, smallCircleSize, smallCircleSize);
                    g.DrawEllipse(myPen, x + offsetSize, y + halfSize - halfSmallCircleSize, smallCircleSize, smallCircleSize);
                    break;
                case 'x':
                    g.DrawEllipse(myPen, x, y, maxSize, maxSize);
                    g.DrawPie(myPen, x, y, maxSize, maxSize, -135, 90);
                    g.DrawPie(myPen, x, y, maxSize, maxSize, 45, 90);
                    break;
                case 'y':
                    g.DrawEllipse(myPen, x, y, maxSize, maxSize);
                    g.DrawPie(myPen, x, y, maxSize, maxSize, -135, 90);
                    g.DrawPie(myPen, x, y, maxSize, maxSize, -45, 90);
                    break;
                case 'z':
                    g.DrawEllipse(myPen, x, y, maxSize, maxSize);
                    g.DrawPie(myPen, x, y, maxSize, maxSize, -45, 180);
                    break;
                case '0':
                    g.DrawEllipse(myPen, x, y, maxSize, maxSize);
                    g.DrawEllipse(myPen, x + halfSize - halfSmallCircleSize/2, y + halfSize - halfSmallCircleSize/2, halfSmallCircleSize, halfSmallCircleSize);
                    break;
                case '1':
                    g.DrawEllipse(myPen, x, y, maxSize, maxSize);
                    g.DrawEllipse(myPen, x + halfSize - halfSmallCircleSize/2, y + halfSize - halfSmallCircleSize/2, halfSmallCircleSize, halfSmallCircleSize);
                    g.DrawLine(myPen, x + halfSize, y, x + halfSize, y + halfSize - halfSmallCircleSize/2);
                    break;
                case '2':
                    g.DrawEllipse(myPen, x, y, maxSize, maxSize);
                    g.DrawEllipse(myPen, x + halfSize - halfSmallCircleSize/2, y + halfSize - halfSmallCircleSize/2, halfSmallCircleSize, halfSmallCircleSize);
                    g.DrawLine(myPen, x + halfSize, y, x + halfSize, y + halfSize - halfSmallCircleSize / 2);
                    g.DrawLine(myPen, x + halfSize, y + maxSize, x + halfSize, y + halfSize + halfSmallCircleSize/2);
                    break;
                case '3':
                    g.DrawPie(myPen, x, y, maxSize, maxSize, -90, 120);
                    g.DrawPie(myPen, x, y, maxSize, maxSize, 30, 120);
                    g.DrawPie(myPen, x, y, maxSize, maxSize, 150, 120);
                    g.FillEllipse(myBrush, x + halfSize - halfSmallCircleSize / 2, y + halfSize - halfSmallCircleSize / 2, halfSmallCircleSize, halfSmallCircleSize);
                    g.DrawEllipse(myPen, x + halfSize - halfSmallCircleSize / 2, y + halfSize - halfSmallCircleSize / 2, halfSmallCircleSize, halfSmallCircleSize);
                    break;
                case '4':
                    g.DrawPie(myPen, x, y, maxSize, maxSize, -90, 90);
                    g.DrawPie(myPen, x, y, maxSize, maxSize, 0, 90);
                    g.DrawPie(myPen, x, y, maxSize, maxSize, 90, 90);
                    g.DrawPie(myPen, x, y, maxSize, maxSize, 180, 90);
                    g.FillEllipse(myBrush, x + halfSize - halfSmallCircleSize / 2, y + halfSize - halfSmallCircleSize / 2, halfSmallCircleSize, halfSmallCircleSize);
                    g.DrawEllipse(myPen, x + halfSize - halfSmallCircleSize / 2, y + halfSize - halfSmallCircleSize / 2, halfSmallCircleSize, halfSmallCircleSize);
                    break;
                case '5':
                    g.DrawPie(myPen, x, y, maxSize, maxSize, -90, 72);
                    g.DrawPie(myPen, x, y, maxSize, maxSize, -18, 72);
                    g.DrawPie(myPen, x, y, maxSize, maxSize, 54, 72);
                    g.DrawPie(myPen, x, y, maxSize, maxSize, 126, 72);
                    g.DrawPie(myPen, x, y, maxSize, maxSize, 198, 72);
                    g.FillEllipse(myBrush, x + halfSize - halfSmallCircleSize / 2, y + halfSize - halfSmallCircleSize / 2, halfSmallCircleSize, halfSmallCircleSize);
                    g.DrawEllipse(myPen, x + halfSize - halfSmallCircleSize / 2, y + halfSize - halfSmallCircleSize / 2, halfSmallCircleSize, halfSmallCircleSize);
                    break;
                case '6':
                    g.DrawEllipse(myPen, x, y, maxSize, maxSize);
                    g.DrawEllipse(myPen, x + halfSize - halfSmallCircleSize / 2, y + halfSize - halfSmallCircleSize / 2, halfSmallCircleSize, halfSmallCircleSize);
                    g.DrawEllipse(myPen, x + halfSize - halfSmallCircleSize, y + halfSize - halfSmallCircleSize, smallCircleSize, smallCircleSize);
                    break;
                case '7':
                    g.DrawPie(myPen, x, y, maxSize, maxSize, -90, 360);
                    g.FillEllipse(myBrush, x + halfSize - halfSmallCircleSize, y + halfSize - halfSmallCircleSize, smallCircleSize, smallCircleSize);
                    g.DrawEllipse(myPen, x + halfSize - halfSmallCircleSize / 2, y + halfSize - halfSmallCircleSize / 2, halfSmallCircleSize, halfSmallCircleSize);
                    g.DrawEllipse(myPen, x + halfSize - halfSmallCircleSize, y + halfSize - halfSmallCircleSize, smallCircleSize, smallCircleSize);
                    break;
                case '8':
                    g.DrawPie(myPen, x, y, maxSize, maxSize, -90, 180);
                    g.DrawPie(myPen, x, y, maxSize, maxSize, 90, 180);
                    g.FillEllipse(myBrush, x + halfSize - halfSmallCircleSize, y + halfSize - halfSmallCircleSize, smallCircleSize, smallCircleSize);
                    g.DrawEllipse(myPen, x + halfSize - halfSmallCircleSize / 2, y + halfSize - halfSmallCircleSize / 2, halfSmallCircleSize, halfSmallCircleSize);
                    g.DrawEllipse(myPen, x + halfSize - halfSmallCircleSize, y + halfSize - halfSmallCircleSize, smallCircleSize, smallCircleSize);
                    break;
                case '9':
                    g.DrawPie(myPen, x, y, maxSize, maxSize, -90, 120);
                    g.DrawPie(myPen, x, y, maxSize, maxSize, 30, 120);
                    g.DrawPie(myPen, x, y, maxSize, maxSize, 150, 120);
                    g.FillEllipse(myBrush, x + halfSize - halfSmallCircleSize, y + halfSize - halfSmallCircleSize, smallCircleSize, smallCircleSize);
                    g.DrawEllipse(myPen, x + halfSize - halfSmallCircleSize / 2, y + halfSize - halfSmallCircleSize / 2, halfSmallCircleSize, halfSmallCircleSize);
                    g.DrawEllipse(myPen, x + halfSize - halfSmallCircleSize, y + halfSize - halfSmallCircleSize, smallCircleSize, smallCircleSize);
                    break;
                default:
                    break;
            }
        }
        
        // save cipher picture
        private void pictureBox1_DoubleClick(object sender, EventArgs e)
        {
            myBitmap.Save(@"cipher.bmp");
            MessageBox.Show("Cipher is saved.");
        }

        // change plaintext -> update cipher
        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            graphicsObj.Clear(Color.Black);
            Draw_Cipher(graphicsObj, textBox1.Text.ToLower());
            picCipher.Image = myBitmap;
        }

        // click cipher image -> generate plain
        private void pictureBox2_MouseClick(object sender, MouseEventArgs e)
        {
            int x = (e.X - offset_x) / 20;
            int y = (e.Y - offset_y) / 20;

            int number;
            if (y == 0)
            {
                number = x;
            }
            else{
                number = y * num_chars_per_line + x + 1;
            }
            if (number < character_set.Length)
            {
                int currentPosition = textBox1.SelectionStart;
                textBox1.Text = textBox1.Text.Insert(currentPosition, character_set[number].ToString());
                graphicsObj.Clear(Color.Black);
                Draw_Cipher(graphicsObj, textBox1.Text.ToLower());
                picCipher.Image = myBitmap;
                // update cursor plain textbox
                textBox1.SelectionStart = currentPosition + 1;
            }
        }

        // change cipher type
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            // update cipher type
            currentCipherType = comboBox1.SelectedIndex;
            // update label of type cipher
            lblCipherType.Text = lstCiphers[currentCipherType];
            // update image of type cipher
            picCipherType.Image = imageList1.Images[currentCipherType];
            // redraw character set into picCharacterSet
            graphicsCharacterSet.Clear(picCharacterSet.BackColor);
            Draw_Cipher(graphicsCharacterSet, lstCharactersets[currentCipherType]);
            picCharacterSet.Image = bitmapCharacterSet;
            // redraw cipher into picCipher
            graphicsObj.Clear(picCipher.BackColor);
            Draw_Cipher(graphicsObj, textBox1.Text.ToLower());
            picCipher.Image = myBitmap;
        }

    }
}
